/*
 * @Description:
 * @Version: 1.0.0
 * @Autor: Ceart <1871321876@qq.com>
 * @Date: 2022-08-05 16:57:27
 * @LastEditors: Ceart
 * @LastEditTime: 2022-08-05 23:12:47
 */
import { execSync } from 'child_process';
import path from 'path';

import { packages } from '../meta/packages';
import { chalkSUCCESS } from './utils';

execSync('npm run build', { stdio: 'inherit' });
execSync('npm run update', { stdio: 'inherit' });

// 发布私有包需要添加--access public
const command = 'npm publish --access public';

Object.values(packages).forEach(({ name }) => {
  execSync(command, {
    stdio: 'inherit',
    cwd: path.resolve(__dirname, '../packages', name, 'dist'),
  });
  console.log(chalkSUCCESS(`Published @guojunquan/${name}`));
});
